import { businessGetList,businessDoAdd,businessDoEdit,businessdoRemove,getDictWordList } from '@/services/knowledgemanagement';

export default {
  namespace:'businessKnowledgeBase',

  state: {
  
  },
  effects: {
    *businessGetList({ payload, callback }, { call, put }) {
      const response = yield call(businessGetList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *businessDoAdd({ payload, callback }, { call, put }) {
      const response = yield call(businessDoAdd, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *businessDoEdit({ payload, callback }, { call, put }) { // 编辑
      const response = yield call(businessDoEdit, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *businessdoRemove({ payload, callback }, { call, put }) { // 删除
      const response = yield call(businessdoRemove, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *getDictWordList({ payload, callback }, { call, put }) { // 指标名称列表
      const response = yield call(getDictWordList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
